#include <function/Function.h>
#include <gtest/gtest.h>

using tpl::Function;

int test_func(int a)
{
  return a;
}

class FunctionTest : public testing::Test
{
public:
  void SetUp() override {}

  void TearDown() override {}
};

TEST(Function, global)
{
  Function<int(int)> f = test_func;
  EXPECT_EQ(f(1), 1);

  auto g = f;
  EXPECT_EQ(f(2), 2);
}

TEST(Function, lamda)
{
  Function<int(int)> f = [](int a) -> int { return a; };

  EXPECT_EQ(f(2), 2);
}

struct Op
{
  int operator()(int a) { return a; }

  int GetValue(int a) { return a; }
};

TEST(Function, Op)
{
  Function<int(int)> f = Op{};

  EXPECT_EQ(f(2), 2);

  auto g = f;
  EXPECT_EQ(g(1), 1);
}
